# List all NMF models
nmfModel()
# or list only the built-in models
nmfModel(builtin.only=TRUE)
# create a NMF object based on one random matrix: the missing matrix is deduced
# Note this only works when using factory method NMF
n <- 50; r <- 3;
w <- matrix(runif(n*r), n, r)
nmfModel(W=w)
# create a NMF object based on random (compatible) matrices
p <- 20
h <- matrix(runif(r*p), r, p)
mod <- nmfModel(W=w, H=h)
# use the model as a seed (initialization) for the default NMF algorithm to fit a target matrix
V <- matrix(runif(n*p), n, p)
nmf(V, seed=mod)
# create an empty NMF model compatible with a given target matrix
nmfModel(V)
# create a NMF object based on incompatible matrices: generate an error
h <- matrix(runif((r+1)*p), r+1, p)
new('NMFstd', W=w, H=h)
# same thing using the factory method: dimensions are corrected and a warning
# is thrown saying that the dimensions used are reduced
nmfModel(W=w, H=h)Run the code above in your browser using DataLab